//矩阵处理规模：1 * k * 8n

#include <stdio.h>
extern int gemm_mNK_1_asm(int _m, int _n, int _k, float alpha, float* _a, float* _b, float* _c, int ldc, float beta, int ldb);
#define GEMM_P 128   //m
#define GEMM_Q 256   //k
#define GEMM_R 128 //n
#define GEMM_UNROLL_M 8
#define GEMM_UNROLL_N 8
int gemm_mNK_1(int m, int n, int k, float alpha, float *a, int lda, float *b, int ldb, float beta, float *c, int ldc){

    int min_i = 0, min_l = 0, min_j = 0;
    int js=0, ls=0, is=0;
    int jjs=0, min_jj = 0;
    int l1stride;
    float *b_temp = b;


    for(js = 0; js < n; js += GEMM_R){
        min_j = n - js;
        if (min_j > GEMM_R) min_j = GEMM_R;
        for(ls = 0; ls < k; ls += min_l){

            min_l = k - ls;

            if (min_l >= GEMM_Q * 2) {

	            min_l  = GEMM_Q;
            } else {
	        if (min_l > GEMM_Q) {
	            min_l = ((min_l / 2 + GEMM_UNROLL_M - 1)/GEMM_UNROLL_M) * GEMM_UNROLL_M;
	                            }
            }

            min_i = m;
            l1stride = 1;
            if (min_i >= GEMM_P * 2) {
	            min_i = GEMM_P;
            } else {
	        if (min_i > GEMM_P) {
	            min_i = ((min_i / 2 + GEMM_UNROLL_M - 1)/GEMM_UNROLL_M) * GEMM_UNROLL_M;
	        } else {
	        l1stride = 0;
	                }
                    }
            //ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_from, sa);
            for(jjs = js; jjs < js + min_j; jjs += min_jj){
	min_jj = min_j + js - jjs;
    if (min_jj >= 3*GEMM_UNROLL_N) min_jj = 3*GEMM_UNROLL_N; //循环展开大小
        else if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
    
    gemm_mNK_1_asm(min_i, min_jj, min_l, alpha, a, (float *)(b_temp) + ldb * jjs, (float *)(c) + ldc * jjs, ldc, beta, ldb);
            }
   b_temp = b_temp + min_l;

    }
  }
}

return 0;
}